/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.rest.front;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.system.bo.req.QztySubmitReq;
import me.zhengjie.modules.system.bo.req.YplyReq;
import me.zhengjie.modules.system.domain.DccQunzhongtianyan;
import me.zhengjie.modules.system.repository.DccYaopinlanyongRepository;
import me.zhengjie.modules.system.service.DccQunzhongtianyanService;
import me.zhengjie.modules.system.service.DccYaopinlanyongService;
import me.zhengjie.modules.system.service.dto.DccYaopinlanyongQueryCriteria;
import me.zhengjie.utils.RedisUtils;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.redis.connection.SortParameters;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.Map;

/**
* @website https://eladmin.vip
* @author cjl
* @date 2023-05-16
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "DCC药品滥用相关管理")
@RequestMapping("/front/yply")
public class FrontYaoPinLanYongController {



    private final DccYaopinlanyongService dccYaopinlanyongService;

    private final DccYaopinlanyongRepository dccYaopinlanyongRepository;



    @Log("查询毒查查药品滥用")
    @ApiOperation("查询毒查查药品滥用")
    @AnonymousAccess
    @PostMapping(value = "/list")
    public ResponseEntity<Object> queryDccYaopinlanyong(@RequestBody YplyReq yplyReq){
        DccYaopinlanyongQueryCriteria criteria =new DccYaopinlanyongQueryCriteria();
        //定义排序规则
//        Sort.Order order = new Sort.Order(Sort.Direction.DESC,"updatedAt");
//        Sort.Order order1 = new Sort.Order(Sort.Direction.DESC,"uage");
        //如果有多个排序条件 建议使用此种方式 使用 Sort.by 替换之前的  new Sort();
//        Sort sort = Sort.by(order,order1);
        Sort sort =Sort.by(Sort.Direction.DESC,"updatedAt");
        Pageable pageable =PageRequest.of(yplyReq.getPage()-1, yplyReq.getSize(),sort);
        Map<String, Object> stringObjectMap = dccYaopinlanyongService.queryAll(criteria, pageable);
        return new ResponseEntity<>(stringObjectMap,HttpStatus.OK);
    }






}